#define DEBUG
#include <cstdio>
#define MAXN 100000

using namespace std;

class Graph {
public:
  int n, m, ind[MAXN+1], to[2*MAXN-1], link[2*MAXN-1], dfn[MAXN+1], dfs[MAXN+1], fa[MAXN+1];
  bool node[MAXN+1];

  void addSide(int x, int y) {
    m++;
    to[m]=y;
    link[m]=ind[x];
    ind[x]=m;
  }

  void build(int o, int fa) {
    for (int i=ind[o]; i; i=link[i]) {
      if (to[i]!=fa) {
	build(to[i], o);
      }
    }
    
    dfn[o]=++dfn[0];
    dfs[dfn[o]]=o;
    this->fa[o]=fa;
  }
};

void sortSide(int a[][2], int l, int r) {
  int i=l, j=r, mid=a[(l+r)/2][1], temp;
  for (; i<=j; ) {
    for (; a[j][1]>mid; j--);
    for (; a[i][1]<mid; i++);
    if (i<=j) {
      temp=a[i][0], a[i][0]=a[j][0], a[j][0]=temp;
      temp=a[i][1], a[i][1]=a[j][1], a[j][1]=temp;
      i++, j--;
    }
  }
  if (i<r) {
    sortSide(a, i, r);
  }
  if (j>l) {
    sortSide(a, l, j);
  }
}

int op1(int x, Graph *g) {
  for (int i=1; i<=g->n; i++) {
    if (!g->node[g->dfs[i]]) {
      x--;
      g->node[g->dfs[i]]=true;
    }
    if (!x) {
      return g->dfs[i];
    }
  }
  return 0;
}

int op2(int x, Graph *g) {
  int i;
  for (i=0; g->node[g->fa[x]]; i++, x=g->fa[x]);
  g->node[x]=false;
  return i;
}

int main() {
#ifdef DEBUG
  freopen("0.in", "r", stdin);
  freopen("0.out", "w", stdout);
#endif

  static Graph g;
  static int side[2*MAXN-1][2];
  int n, t;
  scanf("%d %d", &n, &t);
  g.n=n;
  
  for (int i=1; i<n; i++) {
    scanf("%d %d", side[i*2-1], side[i*2-1]+1);
    side[i*2][0]=side[i*2-1][1], side[i*2][1]=side[i*2-1][0];
  }
  sortSide(side, 1, 2*n-2);
  for (int i=2*n-2; i>0; i--) {
    g.addSide(side[i][0], side[i][1]);
  }
  g.build(1, 0);
 
  for (int i=1; i<=t; i++) {
    int op, x;
    scanf("%d %d", &op, &x);
    printf("%d\n", op==1 ? op1(x, &g) : op2(x, &g));
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
